home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / honeytrouble.swf / scripts / frame_10 / DoAction.as
Encoding:
Text File  |  2007-09-27  |  9.5 KB  |  360 lines

  1. function crtNewBall()
  2. {
  3.    trace("crtNewBall 1.5:" + center_mc._currentframe);
  4.    center_mc.gotoAndPlay(2);
  5. }
  6. function crt_new()
  7. {
  8.    trace("crtNewBall 2.5");
  9.    if(ball == undefined)
  10.    {
  11.       trace("Σ║ºτöƒµû░µ»ìτÉâ");
  12.       if(tmp_ball_ball_type_arr != undefined)
  13.       {
  14.          center_mc.nextBall.type = tmp_ball_ball_type_arr[1];
  15.          center_mc.nextBall2.type = tmp_ball_ball_type_arr[2];
  16.       }
  17.       var _loc2_ = center_mc.nextBall2.type;
  18.       if(tgt_num >= tgt_totalNum && balls_num < 11)
  19.       {
  20.          while(type_num_array[_loc2_] == 0 && balls_num != 0)
  21.          {
  22.             _loc2_ = random(tgt_type) + 1;
  23.          }
  24.       }
  25.       superBall = false;
  26.       var _loc4_ = type_arr[random(type_arr.length)];
  27.       var _loc5_ = _loc2_;
  28.       ball = new Ball("attBall",0,center_mc._x,center_mc._y,_loc2_);
  29.       _root.nowBall = ball;
  30.       canShoot = true;
  31.       shooting = false;
  32.       set_ball_pos(pos_r,center_mc._rotation * AtoR);
  33.       if(_root.jumpBall || _root.boomBall)
  34.       {
  35.          superBall = false;
  36.          if(_root.boomBall)
  37.          {
  38.             _root.boomBall = false;
  39.          }
  40.          else if(_root.jumpBall)
  41.          {
  42.             _root.jumpBall = false;
  43.          }
  44.          PowerNum = 0;
  45.          PowerMC.hong._x = -110;
  46.          PowerMC.hong2._x = -110;
  47.       }
  48.       if(_root.holdBall == undefined || _root.holdBall2 == true && holdBall_mc.hold_mc != undefined && _loc2_ == 12 && hold_mx.num == 0 && heidong_vnt > 1)
  49.       {
  50.          type_arr = [7,9,8,12];
  51.       }
  52.       else
  53.       {
  54.          type_arr = [7,8,9];
  55.       }
  56.       if(_root.jumpBall || _root.boomBall || _root.holdBall)
  57.       {
  58.          if(_root.boomBall)
  59.          {
  60.             _root.boomBall = false;
  61.          }
  62.          else if(_root.jumpBall)
  63.          {
  64.             _root.jumpBall = false;
  65.          }
  66.          else if(_root.holdBall)
  67.          {
  68.             _root.holdBall = false;
  69.          }
  70.          PowerNum = 0;
  71.          PowerMC.hong._x = -110;
  72.          PowerMC.hong2._x = -110;
  73.       }
  74.       _loc2_ = random(tgt_type) + 1;
  75.       if(tgt_num >= tgt_totalNum && balls_num < 11 || balls_num == 12)
  76.       {
  77.          while(type_num_array[_loc2_] == 0 && balls_num != 0)
  78.          {
  79.             _loc2_ = random(tgt_type) + 1;
  80.          }
  81.       }
  82.       if(now_type_tmp_arr.length >= 0 && now_type_tmp_arr[0] != undefined)
  83.       {
  84.          var _loc3_ = random(now_type_tmp_arr.length);
  85.          _loc2_ = now_type_tmp_arr[_loc3_];
  86.          trace(" type = " + _loc2_ + "randomNumx = " + _loc3_ + " arr = " + now_type_tmp_arr + "============ddddddddddddddddddddddddddddffffffffffffffffff================");
  87.       }
  88.       if(PowerNum >= 8)
  89.       {
  90.          _loc2_ = _loc4_;
  91.          PowerNum = 0;
  92.          PowerMC.hong._x = -110;
  93.          PowerMC.hong2._x = -110;
  94.       }
  95.       center_mc.nextBall2.type = center_mc.nextBall.type;
  96.       center_mc.nextBall2.gotoAndStop(center_mc.nextBall.type);
  97.       center_mc.nextBall.type = _loc2_;
  98.       center_mc.nextBall.gotoAndStop(_loc2_);
  99.       tmp_ball_ball_type_arr = [_loc5_,center_mc.nextBall.type,center_mc.nextBall2.type];
  100.       trace(" tmp_ball_ball_type_arr = " + tmp_ball_ball_type_arr);
  101.    }
  102. }
  103. function set_ball_pos(w, rada)
  104. {
  105.    ball.x = center_mc._x + w * Math.cos(rada);
  106.    ball.y = center_mc._y + w * Math.sin(rada);
  107.    ball.holder._x = ball.x;
  108.    ball.holder._y = ball.y;
  109.    ball.holder.flower._rotation = center_mc._rotation;
  110. }
  111. function tgt_hitTest(obj)
  112. {
  113.    if(ball_type_change)
  114.    {
  115.       ball_type_change = false;
  116.       obj.type = tmp_ball_ball_type_arr[0];
  117.    }
  118.    if(obj.type == 10)
  119.    {
  120.       _root.jumpBall = true;
  121.    }
  122.    if(obj.type == 8)
  123.    {
  124.       _root.boomBall = true;
  125.    }
  126.    if(obj.type == 12)
  127.    {
  128.       _root.holdBall = true;
  129.    }
  130.    var _loc8_ = Math.floor(obj.y / grid_width);
  131.    attachBall = undefined;
  132.    var _loc2_ = 0;
  133.    var _loc6_ = 31;
  134.    for(var _loc7_ in tgt_mcs)
  135.    {
  136.       var _loc4_ = obj.x - tgt_mcs[_loc7_]._x;
  137.       var _loc3_ = obj.y - tgt_mcs[_loc7_]._y;
  138.       _loc2_ = Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
  139.       if(_loc2_ < 30 and _loc2_ <= _loc6_)
  140.       {
  141.          trace(_loc7_ + "+++++++++++++++++++hittest this mc");
  142.          _loc6_ = _loc2_;
  143.          attachBall = tgt_mcs[_loc7_];
  144.       }
  145.    }
  146.    if(attachBall._currentframe > 12)
  147.    {
  148.       trace("AAA_currentframe" + tgt_mcs[_loc7_]._currentframe);
  149.       attachBall.removeMovieClip;
  150.       attachBall = undefined;
  151.    }
  152.    if(attachBall != undefined)
  153.    {
  154.       attachBall.shine.gotoAndPlay(2);
  155.       insert_type = obj.type;
  156.       if(attachBall.type == 11)
  157.       {
  158.          insert_type = obj.type;
  159.       }
  160.       trace(attachBall.type + "σ£¿Φ┐ÖΘçîµÅÆσàÑτó░τè╢:" + insert_type + ":" + attachBall._currentframe);
  161.       if(!superBall)
  162.       {
  163.          attach_sound.start(0);
  164.          delete shoot_listener_mc.onEnterFrame;
  165.          if(attachBall.type == 11)
  166.          {
  167.             tgt_insert_start(attachBall,"right");
  168.          }
  169.          else if(Math.atan2(obj.y - attachBall._y,obj.x - attachBall._x) % 360 <= Math.atan2(center_mc._y - attachBall._y,center_mc._x - attachBall._x) % 360)
  170.          {
  171.             tgt_insert_start(attachBall,"left");
  172.          }
  173.          else
  174.          {
  175.             tgt_insert_start(attachBall,"right");
  176.          }
  177.       }
  178.       else
  179.       {
  180.          delete shoot_listener_mc.onEnterFrame;
  181.          attach_sound.start(0);
  182.          delete shoot_listener_mc.onEnterFrame;
  183.          if(Math.atan2(obj.y - attachBall._y,obj.x - attachBall._x) % 360 <= Math.atan2(center_mc._y - attachBall._y,center_mc._x - attachBall._x) % 360)
  184.          {
  185.             tgt_insert_start(attachBall,"left");
  186.          }
  187.          else
  188.          {
  189.             tgt_insert_start(attachBall,"right");
  190.          }
  191.          trace("typetypetype:" + spSuperType);
  192.       }
  193.    }
  194. }
  195. function shoot(x, y)
  196. {
  197.    trace(":::" + ball.holder);
  198.    trace(":::" + ball);
  199.    center_mc.gotoAndPlay("shoot");
  200.    ball.holder.setMask(null);
  201.    var _loc1_ = undefined;
  202.    _loc1_ = shootSpeed / Math.sqrt(x * x + y * y);
  203.    ball.dx = x * _loc1_;
  204.    ball.dy = y * _loc1_;
  205.    shoot_sound.start(0.1);
  206.    if(dir_bool)
  207.    {
  208.       MballSD = 2;
  209.    }
  210.    else
  211.    {
  212.       MballSD = 1;
  213.    }
  214.    shoot_listener_mc.onEnterFrame = function()
  215.    {
  216.       if(!game_pause)
  217.       {
  218.          shootStep();
  219.       }
  220.    };
  221. }
  222. function shootStep()
  223. {
  224.    ball.x += ball.dx * MballSD;
  225.    ball.y += ball.dy * MballSD;
  226.    crtShadow();
  227.    if(ball.outOfScene())
  228.    {
  229.       clearBall();
  230.       if(!m_lock)
  231.       {
  232.          crtNewBall();
  233.       }
  234.    }
  235.    else if(mouth_start.pro_area.hitTest(ball.x,ball.y,true))
  236.    {
  237.       trace("µ║Éσñ┤Σ┐¥µèñ,τ¼¼Σ╕ǵ¼í");
  238.       mouth_start.pro_area.gotoAndPlay(2);
  239.       pro_sound.start(0);
  240.       clearBall();
  241.       if(!m_lock)
  242.       {
  243.          crtNewBall();
  244.       }
  245.    }
  246.    else
  247.    {
  248.       tgt_hitTest(ball);
  249.    }
  250.    if(attachBall == undefined)
  251.    {
  252.       ball.x += ball.dx;
  253.       ball.y += ball.dy;
  254.       crtShadow();
  255.       if(ball.outOfScene())
  256.       {
  257.          clearBall();
  258.          if(!m_lock)
  259.          {
  260.             crtNewBall();
  261.          }
  262.       }
  263.       else if(mouth_start.pro_area.hitTest(ball.x,ball.y,true))
  264.       {
  265.          trace("µ║Éσñ┤Σ┐¥µèñ,τ¼¼Σ║îµ¼í");
  266.          mouth_start.pro_area.gotoAndPlay(2);
  267.          pro_sound.start(0);
  268.          clearBall();
  269.          if(!m_lock)
  270.          {
  271.             trace("Σ║ºτöƒµû░τÉâ");
  272.             crtNewBall();
  273.          }
  274.       }
  275.       else
  276.       {
  277.          tgt_hitTest(ball);
  278.       }
  279.    }
  280.    ball.holder._x = ball.x;
  281.    ball.holder._y = ball.y;
  282.    updateAfterEvent();
  283. }
  284. function center_rotation()
  285. {
  286.    if(!m_lock && !drag_center)
  287.    {
  288.       var _loc1_ = Math.atan2(_ymouse - center_mc._y,_xmouse - center_mc._x);
  289.       center_mc._rotation = _loc1_ * RtoA;
  290.       if(!shooting)
  291.       {
  292.          set_ball_pos(pos_r,_loc1_);
  293.          setMotherDir(_loc1_);
  294.       }
  295.    }
  296. }
  297. function ballShoot()
  298. {
  299.    if(canShoot && !m_lock && ball != undefined)
  300.    {
  301.       shoot(_xmouse - center_mc._x,_ymouse - center_mc._y);
  302.       shooting = true;
  303.       canShoot = false;
  304.       dir_mc.clear();
  305.    }
  306. }
  307. function crtShadow()
  308. {
  309.    if(ball_shadow && ball.holder != undefined)
  310.    {
  311.       ball_shadowID--;
  312.       if(ball_shadowID <= 1)
  313.       {
  314.          ball_shadowID = 800;
  315.       }
  316.       if(!superBall)
  317.       {
  318.          ballScene.attachMovie("ball_shadow_mc","sh_mc" + ball_shadowID,ball_shadowID);
  319.          ballScene["sh_mc" + ball_shadowID].c = new Color(ballScene["sh_mc" + ball_shadowID]);
  320.          ballScene["sh_mc" + ball_shadowID].c.setRGB(flower_array[ball.type - 1]);
  321.       }
  322.       else
  323.       {
  324.          ballScene.attachMovie("superball_shadow_mc","sh_mc" + ball_shadowID,ball_shadowID);
  325.       }
  326.       ballScene["sh_mc" + ball_shadowID]._x = ball.x;
  327.       ballScene["sh_mc" + ball_shadowID]._y = ball.y;
  328.    }
  329. }
  330. shootSpeed = width * 0.6;
  331. sceneWidth = 600;
  332. sceneHeight = 450;
  333. grid_width = 60;
  334. pos_r = 36;
  335. Ball.init(ballScene,shootSpeed,sceneWidth,sceneHeight,width,20);
  336. xNum = Math.ceil(sceneWidth / grid_width);
  337. yNum = Math.ceil(sceneHeight / grid_width);
  338. center_mc.nextBall._visible = false;
  339. center_mc.nextBall.stop();
  340. center_mc.nextBall2._visible = false;
  341. center_mc.nextBall2.stop();
  342. m_lock = false;
  343. area = new Array();
  344. i = 0;
  345. while(i < xNum)
  346. {
  347.    area[i] = new Array();
  348.    j = 0;
  349.    while(j < yNum)
  350.    {
  351.       area[i][j] = new Object();
  352.       area[i][j].tgt_ball = new Array();
  353.       j++;
  354.    }
  355.    i++;
  356. }
  357. myGrid = new Grid(grid_width,xNum,yNum,area);
  358. var spSuperType;
  359. type_arr = [7,8,9,12];
  360.